<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
//=============================================================//
//Query File for Crontab Control (BigDaddy v2)
//Duleepa Wijyawardhana, 15.03.2004
//=============================================================//


switch($_REQUEST["action"])
{
    case "addnewcategory":
		$BigDaddyControl->SetCronCategory($_POST["catname"]);
		$redirectTo="page=CronCategory";
        break;
    case "editcategory":
		$BigDaddyControl->SetCronCategory($_POST["catname"],$_POST["catID"]);
        $redirectTo="page=CronCategory";
        break;
    case "deletecategory":
		
		$BigDaddyControl->RemoveCronCategory($_REQUEST["catID"]);
	    $redirectTo="page=CronCategory";
        break;
    case "addcron":
	
		$aInfo["filename"] = $_POST["filename"];
		$aInfo["serverID"] = $_POST["serverID"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["mon_threshold"] = $_POST["mon_threshold"];
		$aInfo["notes"] = $_POST["notes"];
		$aInfo["cat"] = $_POST["cat"];
		
		$nInsertID = $BigDaddyControl->SetCron($aInfo);
        $redirectTo="page=CronViewDetails&cronID=".$nInsertID;
		break;
    case "editcron":
        $aInfo["filename"] = $_POST["filename"];
		$aInfo["serverID"] = $_POST["serverID"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["mon_threshold"] = $_POST["mon_threshold"];
		$aInfo["notes"] = $_POST["notes"];
		$aInfo["cat"] = $_POST["cat"];
        
		$BigDaddyControl->SetCron($aInfo, $_POST["cronID"]);
        $redirectTo="page=CronViewDetails&cronID=".$_POST["cronID"];
        break;
    case "enablecron":
		$BigDaddyControl->SetCronEnabled($_REQUEST["cronID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "clearruninfo":
		$BigDaddyControl->SetCronLastRunToEmpty($_REQUEST["cronID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "disablecron":
		$BigDaddyControl->SetCronDisabled($_REQUEST["cronID"]);
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "deletecron":
		$BigDaddyControl->RemoveCron($_REQUEST["cronID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "enableall":
		$BigDaddyControl->SetCronEnabledByCategory($_REQUEST["catID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "enablemonall":
        $BigDaddyControl->SetCronMonitoringEnabledByCategory($_REQUEST["catID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "enablemoncron":
		$BigDaddyControl->SetCronMonitoringEnabled($_REQUEST["cronID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		break;
    case "disablemoncron":
		$BigDaddyControl->SetCronMonitoringDisabled($_REQUEST["cronID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		break;
    case "disableall":
        $BigDaddyControl->SetCronDisabledByCategory($_REQUEST["catID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "disablemonall":
        $BigDaddyControl->SetCronMonitoringDisabledByCategory($_REQUEST["catID"]);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "delaycron":
		$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
		$BigDaddyControl->SetCronDelayed($_REQUEST["cronID"],$delayUntil );
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "delaycronall":
		$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
		$BigDaddyControl->SetCronDelayedByCategory($_REQUEST["catID"], $delayUntil);
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "resetnormal":
        //Get Crontab INI
		$BigDaddyControl->SetCronGlobalStatusNormal();
		$redirectTo=$_SESSION["sessdata"]["pagefrom"];

        break;
    case "globaldisable":
        //Get Crontab INI
		$BigDaddyControl->SetCronGlobalStatusDisabled();
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "globaldisablemonitoring":
        //Get Crontab INI
		$BigDaddyControl->SetCronGlobalMonitoringStatusDisabled();
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "globaldelay":
        $delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
		$BigDaddyControl->SetCronGlobalStatusDelayed($delayUntil);
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
}



if ($redirectTo!="")
{
    header("Location: /index.html?".$redirectTo);
    exit;
}
else
{
    header("Location: /index.html");
    exit;
}

?>
